package com.example.chenduoyun.safe.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.example.chenduoyun.safe.R;
import com.example.chenduoyun.safe.utils.ConstantValue;
import com.example.chenduoyun.safe.utils.SpUtils;
import com.example.chenduoyun.safe.view.SettingItemView;

/**
 * @author by created chen cloudy 2018/9/7 14:13
 **/

public class SettingActivity extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        initUpdate();
        initPlaceCall();
    }

    private void initPlaceCall() {
        final SettingItemView siv_placeCall = findViewById(R.id.siv_placecall);
        siv_placeCall.setCheck(SpUtils.getBoolean(this, ConstantValue.PLACE_CALL, false));
        siv_placeCall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean isCheck = siv_placeCall.isCheck();
                siv_placeCall.setCheck(!isCheck);
                SpUtils.putBoolean(getApplicationContext(), ConstantValue.PLACE_CALL, !isCheck);
            }
        });
    }

    private void initUpdate() {
        final SettingItemView siv_update = findViewById(R.id.siv_update);
        siv_update.setCheck(SpUtils.getBoolean(this, ConstantValue.OPEN_UPDATE, false));
        siv_update.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean isCheck = siv_update.isCheck();
                siv_update.setCheck(!isCheck);
                SpUtils.putBoolean(getApplicationContext(), ConstantValue.OPEN_UPDATE, !isCheck);
            }
        });

    }

}
